#include <functional>
#include <map>
#include <variant>

#include "jsi_executor/NativeModule.h"
#include "bridge/NativeToJSBridge.h"

namespace test_native_module {
using namespace jsiexecutor;
using FunctionType = std::function<Dynamic(int, int)>;

class MyAsyncModule : public NativeModule {
 public:
  MyAsyncModule(std::shared_ptr<bridge::NativeToJSBridge> nativeToJsBridge,
                std::shared_ptr<bridge::MessageQueue> nativeQueue);
  std::string getName() override;
  std::vector<MethodDescriptor> getMethods() override;
  Dynamic getConstants() override;
  void invokeSync(unsigned int methodId, std::vector<Dynamic>& args) override;
  void invokeAsync(unsigned int methodId, std::vector<Dynamic>& args, unsigned int callbackId) override;
  void addFunc(std::string name, FunctionType func, MethodType funcType);
  Dynamic testMax(int x, int y);

 private:
  std::vector<MethodDescriptor> methodNames_;
  std::map<std::string, FunctionType> funcMap_;
  std::shared_ptr<bridge::NativeToJSBridge> nativeToJsBridge_;
  std::shared_ptr<bridge::MessageQueue> nativeQueue_;
};
}  // namespace test_native_module
